import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Login from "../views/Login.vue";

// 导入文章列表
import PostList from "../views/PostList.vue";
// 导入发布文章
import EditPost from "../views/EditPost.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    children: [
      // 文章列表子路由
      {
        path: "postlist",
        component: PostList,
      },
      // 发布文章子路由
      {
        path: "editpost",
        component: EditPost,
      },
    ],
  },
  {
    path: "/login",
    name: "loginPage",
    component: Login,
  },
];

const router = new VueRouter({
  routes,
});

export default router;
